package com.common.factory.impl;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.common.authentication.Oauth2PasswordModeAuthentication;
import com.common.factory.AbstractOauth2AuthenticationFactoryStrategyWrapper;
import com.common.pojo.Oauth2PasswordMode;
import com.common.pojo.Oauth2TestMode;
import com.common.strategy.AccountTypeStrategy;
import com.common.strategy.impl.PasswordAccountTypeStrategy;
import com.common.strategy.impl.TestAccountTypeStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

/**
 * @Description: 密码模式工厂
 */
@Component
public class Oauth2AuthenticationPasswordFactory extends AbstractOauth2AuthenticationFactoryStrategyWrapper<Oauth2PasswordMode, Oauth2PasswordModeAuthentication, PasswordAccountTypeStrategy> {


    @Override
    public boolean support(String grantType) {
        return "password".equals(grantType);
    }

    @Override
    protected Oauth2PasswordMode createMode(JSONObject bodyJsonObject) {
        return JSONUtil.toBean(bodyJsonObject, Oauth2PasswordMode.class);
    }
}
